package view;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;

import model.dtos.SectorDTO;
import java.util.Collection;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ApplicationActionMap;

import controllers.AdministracionController;

import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class SectorModificacion extends javax.swing.JPanel {
        private JLabel jLabelSectorID;
        private JComboBox jComboBoxSectorID;
        private JButton jButtonSectorCancelar;
        private JButton jButtonSectorID;
        private static SectorModificacion frameSectorBusquedaInstancia;
        private JTextField jTextField1;
        private JLabel jLabel1;
        private AbstractAction abstractActionSectorAceptar;
        private SectorModificacion frameSectorModificacion;
        
        public static SectorModificacion getInstancia() {
                if(frameSectorBusquedaInstancia==null){
                        frameSectorBusquedaInstancia=new SectorModificacion();
                }
                return frameSectorBusquedaInstancia;
        }
        
        
        
        private SectorModificacion() {
                super();
                initGUI();
        }
        
        private void initGUI() {
                try {
                        this.setLayout(null);
                        {
                                jLabelSectorID = new JLabel();
                                this.add(jLabelSectorID);
                                jLabelSectorID.setText("Seleccione el ID del Sector que desea cambiar:      ");
                                jLabelSectorID.setBounds(12, 12, 296, 16);
                        }
                        {
                        		Collection<SectorDTO> _sectores = AdministracionController.getInstancia().getSectores();
                                jComboBoxSectorID = new JComboBox();
                                for (SectorDTO _sector : _sectores)
                        		{
                                	jComboBoxSectorID.addItem(_sector.getNombre());
                        		}

                                this.add(jComboBoxSectorID);
                                jComboBoxSectorID.setBounds(95, 34, 189, 23);
                        }
                        {
                                jButtonSectorID = new JButton();
                                this.add(jButtonSectorID);
                                jButtonSectorID.setText("Aceptar");
                                jButtonSectorID.setBounds(79, 136, 90, 24);
                                jButtonSectorID.setAction(getAbstractActionSectorAceptar());
                        }
                        {
                                jButtonSectorCancelar = new JButton();
                                this.add(jButtonSectorCancelar);
                                this.add(getJLabel1());
                                this.add(getJTextField1());
                                jButtonSectorCancelar.setText("Cancelar");
                                jButtonSectorCancelar.setBounds(169, 137, 99, 23);
                                jButtonSectorCancelar.setAction(getAppActionMap().get("actionCancelar"));
                        }
                        this.setSize(379, 182);
                        Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
        
        private AbstractAction getAbstractActionSectorAceptar() {
                if(abstractActionSectorAceptar == null) {
                        abstractActionSectorAceptar = new AbstractAction("Aceptar", null) {
                                public void actionPerformed(ActionEvent evt) {
                                        frameSectorBusquedaInstancia.setVisible(false);
                                }
                        };
                }
                return abstractActionSectorAceptar;
        }
        
        @Action
        public void actionCancelar() {
                frameSectorBusquedaInstancia.setVisible(false);
        }
        
    /**
    * Returns the action map used by this application.
     * Actions defined using the Action annotation
     * are returned by this method
     */
        private ApplicationActionMap getAppActionMap() {
                return Application.getInstance().getContext().getActionMap(this);
        }
    
    private JLabel getJLabel1() {
    	if(jLabel1 == null) {
    		jLabel1 = new JLabel();
    		jLabel1.setBounds(31, 86, 144, 16);
    		jLabel1.setText("Nombre de Sector");
    	}
    	return jLabel1;
    }
    
    private JTextField getJTextField1() {
    	if(jTextField1 == null) {
    		jTextField1 = new JTextField();
    		jTextField1.setBounds(187, 83, 121, 23);
    	}
    	return jTextField1;
    }

}